package com.cn.ycy.websocket;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.Random;

@Controller
@RequestMapping("ws")
public class WsController {

  @Autowired
  WebSocket webSocket;

  @RequestMapping(value = "/load", method = RequestMethod.GET)
  @ResponseBody
  public String loadPost(
  ) {

    int random = new Random(10).nextInt(10);
    webSocket.sendMessage(String.valueOf(random));

    return "hello world";
  }

}
